package hn.sigit.logic.general.impl;


import hn.sigit.logic.general.ResourceBundleHelper;

import java.util.MissingResourceException;

import javax.ejb.Stateless;

import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.core.SeamResourceBundle;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

@Stateless
@Scope(value=ScopeType.SESSION)
@Name(ResourceBundleHelper.NAME)
@AutoCreate
public class ResourceBundleHelperImpl implements ResourceBundleHelper {
	private SeamResourceBundle resourceBundle;
	
	public ResourceBundleHelperImpl() {
	}
	
	public String loadMessage(String str) {
		resourceBundle = (SeamResourceBundle)Component.getInstance("org.jboss.seam.core.resourceBundle");
		String retval = "";

		try {
			retval = resourceBundle.getString(str);
		}
		catch (MissingResourceException mre) {
			retval = str;
		}
		catch (NullPointerException npe) {
			retval = str;
		}
		
		return retval;
	}
}
